﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using XNAnimation;
using XNAnimation.Controllers;

namespace Alone.GameObjects
{
	public class LocalPlayer : BasePlayer
	{
		private int jetpack = 50;
		private float jumpForce = 2;
		private float jetpackForce = 20;
		private float jumppositiony;

        /// <summary>
        /// Initializes a new instance of the <see cref="LocalPlayer"/> class.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="animationController">The animation controller.</param>
        /// <param name="effect">The effect.</param>
        /// <param name="position">The position.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="velocity">The velocity.</param>
		public LocalPlayer(SkinnedModel model, AnimationController animationController, Effect effect, Vector3 position, Vector2 rotation, float scale, Vector3 velocity) :
			base(model, animationController, effect, position, rotation, scale, velocity)
		{
			hp = 200;
			jetpack = 50;
		}

		/// <summary>
		/// Gets or sets the jump force.
		/// </summary>
		/// <value>The jump force.</value>
		public float JumpForce
		{
			get { return jumpForce; }
			set { jumpForce = value; }
		}

		/// <summary>
		/// Gets or sets the jetpack force.
		/// </summary>
		/// <value>The jetpack force.</value>
		public float JetpackForce
		{
			get { return jetpackForce; }
			set { jetpackForce = value; }
		}

		/// <summary>
		/// Gets or sets the jetpack.
		/// </summary>
		/// <value>The jetpack.</value>
		public int Jetpack
		{
			get { return jetpack; }
			set { jetpack = value; }
		}

        /// <summary>
        /// Sets the jump position Y.
        /// </summary>
        /// <value>The jump position Y.</value>
		public float JumpPositionY
		{
			set { this.jumppositiony = value; }
		}

		/// <summary>
		/// Uses the jetpack.
		/// </summary>
		/// <returns></returns>
		public bool useJetpack()
		{
			if (jetpack == 0)
				return false;
			jetpack--;
			return true;
		}

		/// <summary>
		/// Jumps this instance.
		/// </summary>
		/// <returns></returns>
		public bool jump()
		{
			if (Position.Y > jumppositiony)
				return false;
			return true;
		}

		/// <summary>
		/// Decs the health.
		/// </summary>
		/// <param name="points">The points.</param>
		public void decHealth(int points)
		{
			Hp -= points;
			if (Hp < 0)
				Hp = 0;
		}

		/// <summary>
		/// Incs the health.
		/// </summary>
		/// <param name="points">The points.</param>
		public void incHealth(int points)
		{
			Hp += points;
			if (Hp > 200)
				Hp = 200;
		}
	}
}
